local skel = fk.CreateSkill {
  name = "emo__qianfei",
}

Fk:loadTranslationTable{
  ["emo__qianfei"] = "潜绯",
  [":emo__qianfei"] = "①一名角色于其回合内使用的第一张有目标角色的黑色牌结算后，你可以弃置一张牌并选一项：1.令此牌额外结算一次；2.令一个目标回复1点体力；②摸牌阶段，你可额外摸X张牌（X为手牌数小于你的角色数）。",

  ["#emo__qianfei-recover"] = "潜绯：令一个目标回复1点体力；“取消”：令%arg再结算一次",
  ["#emo__qianfei-invoke"] = "潜绯：可弃一张牌，令 %dest 使用的 %arg 额外结算或一个目标回复体力",
}

skel:addEffect(fk.CardUseFinished, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and not player:isNude() and target.phase ~= Player.NotActive
    and target:getMark("emo__qianfei-turn") == 0 and data.card.color == Card.Black and data.tos and #data.tos > 0
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    room:addPlayerMark(target, "emo__qianfei-turn")
    local targets = room:deadPlayerFilter(data.tos)
    if #targets == 0 then return false end
    local cards = room:askToDiscard(player, {
      min_num = 1, max_num = 1, skill_name = skel.name, include_equip = true, skip = true,
      prompt = "#emo__qianfei-invoke::".. data.from.id ..":"..data.card:toLogString()
    })
    if #cards > 0 then
      event:setCostData(self, { cards = cards })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:throwCard(event:getCostData(self).cards, skel.name, player, player)
    if player.dead then return end
    local targets = room:deadPlayerFilter(data.tos)
    if #targets == 0 then return end
    local tos = room:askToChoosePlayers(player, {
      targets = targets, min_num = 1, max_num = 1, skill_name = skel.name,
      prompt = "#emo__qianfei-recover:::"..data.card:toLogString(),
    })
    if #tos > 0 then
      local to = tos[1]
      if to:isWounded() then
        room:recover({ who = to, num = 1, recoverBy = player, skillName = skel.name })
      end
    else
      room:useCard{
        from = data.from, tos = targets, extraUse = true, card = data.card,
      }
    end
  end,
})

skel:addEffect(fk.DrawNCards, {
  anim_type = "drawcard",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and table.find(player.room.alive_players,
    function(p) return p:getHandcardNum() < player:getHandcardNum() end)
  end,
  on_use = function(self, event, target, player, data)
    data.n = data.n + #table.filter(player.room.alive_players, function(p) return p:getHandcardNum() < player:getHandcardNum() end)
  end,
})

return skel
